package java_thinking.unit_15._15_7;

/**
 * @Description :   验证泛型边界转型，与非泛型的案例反编译后的代码没有区别
 * @author: cww
 * @DateTime: 2019/4/4 8:44
 */

public class T_Boders_1<T> {
    private T obj;
    public void set(T obj){
        this.obj = obj;
    }
    public T get(){
        return obj;
    }

    public static void main(String[] args) {
        T_Boders_1<String> tBoders1 = new T_Boders_1<>();
        tBoders1.set("Item");
        //get之后已经无需转型了，泛型在进入对象和离开边界的时候自动做了转型
        //边界就是发生动作的地方
        String s = tBoders1.get();
    }
}

/**
public class T_Boders_1<T> {
    public T_Boders_1();
    Code:
        0: aload_0
        1: invokespecial #1                  // Method java/lang/Object."<init>":()V
        4: return

    public void set(T);
    Code:
        0: aload_0
        1: aload_1
        2: putfield      #2                  // Field obj:Ljava/lang/Object;
        5: return

    public T get();
    Code:
        0: aload_0
        1: getfield      #2                  // Field obj:Ljava/lang/Object;
        4: areturn

    public static void maindemo(java.lang.String[]);
    Code:
        0: new           #3                  // class T_Boders_1
        3: dup
        4: invokespecial #4                  // Method "<init>":()V
        7: astore_1
        8: aload_1
        9: ldc           #5                  // String Item
        11: invokevirtual #6                  // Method set:(Ljava/lang/Object;)V
        14: aload_1
        15: invokevirtual #7                  // Method get:()Ljava/lang/Object;
        18: checkcast     #8                  // class java/lang/String
        21: astore_2
        22: return
}
*/